//
//  FSHomeViewController.swift
//  fushp_weibo
//
//  Created by fushp on 2017/11/9.
//  Copyright © 2017年 fushp. All rights reserved.
//

import UIKit
private let cell = "cellid"
class FSHomeViewController: FSBaseViewController {

   
    private lazy var statuslist = [String]()
    
    override func loaddata() {
        //MARK: --延迟加载数据
        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
            for i in 0 ..< 10{
                if self.ispullUp {
                    self.statuslist.append("上拉\(i)")
                }else {
                    self.statuslist.insert(String(i), at: 0)
                }
            }
            self.ispullUp = false
            self.refreshControl?.endRefreshing()
            self.tableview?.reloadData()
        }
      
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    @objc private func showFriends() {
        print(#function)
        let demove = FSDemoViewController()
        navigationController?.pushViewController(demove, animated: true)
    }
    override func setUI() {
        super.setUI()
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "好友", style: .plain, target:self , action: #selector(showFriends))
        tableview?.register(UITableViewCell.self, forCellReuseIdentifier: cell)
    }
   

}

extension FSHomeViewController{
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell_ = tableview?.dequeueReusableCell(withIdentifier: cell)
        cell_?.textLabel?.text = statuslist[indexPath.row]
        return cell_!
    }
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return statuslist.count
    }
}

